package com.weixiaoit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.weixiaoit.ajax.util.DBHelp;
import com.weixiaoit.ajax.util.RowMapper;
import com.weixiaoit.entity.City;

public class CityDao {
	DBHelp<City> db=new DBHelp<City>();
	public List<City> findByProvinceId(String id) {
		String sql="select ct.id ,city,provinceid from t_city as ct left join t_province as pc on ct.provinceid=pc.id where pc.id=? ";
		return db.executeQueryForList(sql, new CityRowMapper(), id);
	}
	private class CityRowMapper implements RowMapper<City>{

		public City mapperRow(ResultSet rs) throws SQLException {
			City c=new City();
			c.setCity(rs.getString("city"));
			c.setId(rs.getString("id"));
			c.setProvinceId(rs.getString("provinceid"));
			return c;
		}
		
		
	}

}
